package prosjekt;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.sql.SQLException;

import javax.swing.*;

/**
 * Main window JFrame
 * @author Henning
 *
 */
@SuppressWarnings("serial")
public class Hovedvindu extends JFrame implements WindowListener{
	
	{
		try {
			javax.swing.UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Default constructor
	 * @throws SQLException
	 */
	public Hovedvindu() throws SQLException {
		super("Pizzarestaurant AS");
		Hovedpanel hPanel = new Hovedpanel();
		add(hPanel);

		pack();
		//setExtendedState(MAXIMIZED_BOTH);
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		addWindowListener(this);
	}
	
	/**
	 * Main method to start main window
	 * @param args Program args
	 * @throws SQLException
	 */
	public static void main(String[] args) throws SQLException {
		new Hovedvindu();
	}

	@Override
	public void windowActivated(WindowEvent arg0) {
		//Ignored
	}

	@Override
	public void windowClosed(WindowEvent arg0) {
		//Ignored		
	}

	@Override
	public void windowClosing(WindowEvent arg0) {
		DBManager.getInstance().close();
		System.exit(1);
	}

	@Override
	public void windowDeactivated(WindowEvent arg0) {
		//Ignored		
	}

	@Override
	public void windowDeiconified(WindowEvent arg0) {
		//Ignored		
	}

	@Override
	public void windowIconified(WindowEvent arg0) {
		//Ignored		
	}

	@Override
	public void windowOpened(WindowEvent arg0) {
		//Ignored		
	}
}